import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User:
 * Date: 2025-10-08
 * Time: 14:28
 */
public class demo2 {
    public static void main(String[] args) {
        Object locker = new Object();

        Thread t1 = new Thread(() -> {
           try{
               System.out.println("wait 之前");
               synchronized(locker){
                   locker.wait();
               }
               System.out.println("wait 之后");
           }catch (InterruptedException e){
               e.printStackTrace();
           }
        });

        Thread t2 = new Thread(() -> {
            Scanner sc = new Scanner(System.in);
            System.out.println("请输入任意内容，通知唤醒t1");
            sc.next();
            synchronized(locker){
                locker.notify();
            }
        });

        t1.start();
        t2.start();
    }
}
